#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int main()
{
	//int a = 0;
	//int b = 2;
	//
	////if (a == 1)
	////	if (b == 2)
	////		printf("hehe\n");
 ////   else
	////	printf("haha\n");
	////实际没有输出

	//if (a == 1)
	//	if (b == 2)
	//		printf("hehe\n");
	//	else
	//		printf("haha\n");
	////else与上面最近的if配对，而不是与对齐的if配对

	//if (a == 1)
	//{
	//	if (b == 2)
	//		printf("hehe\n");

	//}
	//else
	//	printf("haha\n");

	//-------------------------------------------------------------

	//scanf("%d", &a);

	////if (a == 3)
 ////       printf("hehe\n");
	////else
 ////       printf("haha\n");

	////if (a = 3)
	////	printf("hehe\n");
	////else
	////	printf("haha\n");

	//if (3 == a)
	//	printf("hehe\n");
	//else
	//	printf("haha\n");
	////建议：当一个变量和一个常量比较是否相等时，常量值放在左边，变量放在右边


	//-------------------------------------------------------------

	//int i = 6;
	//int j = 9;
	//int k = 3;

	////if(i < j < k)//比较顺序：i < j 成立，表达式返回1；1 < k成立，表达式返回1；整个表达式成立，返回1
 ////       printf("hehe\n");
 ////   else
 ////       printf("haha\n");

	////正确写法：
	//if (i < j && j < k)
	//	printf("hehe\n");
	//else
	//	printf("haha\n");

	//-------------------------------------------------------------

	////条件操作符
 //   int a = 6;
 //   int b = 2;
	//int c = (a > b ? a : b);

	//////等价于
 ////   if (a > b)
 ////       c = a;
 ////   else
 ////       c = b;

 //   printf("%d\n", c);

	//-------------------------------------------------------------

	//逻辑运算符
	//int flag = 0;

	//scanf("%d", &flag);

	//if (flag)//flag为真（非0），则执行if语句块。等价于if(flag != 0)
	//	printf("hehe\n");
	//else if (!flag)//flag为假（0），则执行else if语句块。等价于if(flag == 0)
	//	printf("haha\n");
	//else
 //       printf("heihei\n");

	int i = 0, a = 0, b = 2, c = 3, d = 4;

	//i = (a++ && ++b && d++);
	//printf("a = %d\nb = %d\nc = %d\nd = %d\ni = %d", a, b, c, d, i);// 1 2 3 4 0
	////a++, 先使用再赋值，一开始为0，用&&连接，所以整个表达式为0，且不会再执行后面的语句

	i = (a++ || ++b || d++);
	printf("a = %d\nb = %d\nc = %d\nd = %d\ni = %d", a, b, c, d, i);
	//执行到++b时，表达式结果非0，所以不再执行后面的语句

	return 0;
}